<template>
  <div class="myContainer">
    <el-row class="myTitleBorderBottom">
      <el-col :span="12" class="myLineHeight_40px">{{this.title}}</el-col>
    </el-row>
    <el-row class="myMarginTop_10px" :gutter="10">
      <el-col :span="4">
        <template>
          <el-select 
            v-model="shoptype"
            clearable
            placeholder="店铺类型">
            <el-option
              v-for="item in shopList"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </template>
      </el-col>
      <el-col :span="4">
        <el-input placeholder="请输入关键词" v-model="kw"></el-input>
      </el-col>
      <el-col :span="3">
        <el-button type="primary" class="myBgGreen" @click="onSearch">查 询</el-button>
      </el-col>
    </el-row>
    <el-row class="myMarginTop_10px">
      <el-col :span="24">
        <el-table
          ref="multipleTable"
          v-loading="loading"
          :data="tableData"
          :border = true
          :stripe = true
          style="width: 100%"
          @selection-change="handleSelectionChange">
          <el-table-column
            label="序号"
            type="index"
            width="60">
          </el-table-column>
          <!-- <el-table-column
            prop="USER_ID"
            label="所属用户"
            >
          </el-table-column>  -->
          <el-table-column
            prop="STORENAME"
            label="店铺名称"
            >
          </el-table-column> 
          <el-table-column
            prop="CONTACTER"
            label="联系人"
            >
          </el-table-column> 
          <el-table-column
            prop="TEL"
            label="电话"
            >
          </el-table-column> 
          <el-table-column
            label="转账方式"
            >
            <template scope="scope">
              {{scope.row.ACCOUNTTYPE | onAccountType}}
            </template>
          </el-table-column> 
          <el-table-column
            prop="ACCOUNTNAME"
            label="转账用户"
            >
          </el-table-column> 
          <el-table-column
            prop="ACCOUNTNUM"
            label="转账账号"
            >
          </el-table-column> 
          <el-table-column
            label="操作"
            width="100">
            <template scope="scope">
              <el-button type="text primary" @click="onEidt(scope.row.STORE_ID)" class="look" size="small">编辑</el-button>
            </template>
          </el-table-column>
        </el-table>
        <div class="block">                    
          <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="page_num"
            :page-sizes="[10, 15]"
            :page-size="page_size"
            layout="total, sizes, prev, pager, next, jumper"
            :total="total">
          </el-pagination>
        </div>
      </el-col>
    </el-row>   
  </div>
</template>

<style scoped>
  .myContainer{
    background: #fff;
    padding: 10px;
  }
  .myTitleBorderBottom{
    color: #000;
    font-weight: 500;
    font-size: 16px;
    border-bottom: 1px solid #dbdbdb;
  }
  .myBgGreen{
    background: #00c2a9;
    border-color: #00c2a9;
    color: #fff;
    margin-top:2px;
  }
  .myBgGreen:hover{
    background: #33ceba;
  }
  .myTextAlignRight{
    text-align: right;
  }
  .myLineHeight_40px{
    line-height: 40px;
  }
  .myMarginTop_10px{
    margin-top: 10px;
  }
  .myColorRed{
    color: #f00;
  }
</style>

<script>
  import { getAccountList } from '@/api/online';
  import qs from "querystring";

  export default {
    data(){
      return{  
        title:"店铺店主账户信息管理",    
        loading:false,
        tableData:[],  
        total:null, //总条数  
        page_num: 1, //当前页码
        page_size: 10, //每页显示多少条 
        kw:"",
        shoptype:"",
        shopList:[{label:"超市商品",value:1},{label:"餐饮商品",value:2},{label:"团购商品",value:3}]
      }
    },
    created() {
      document.title=this.title;
      this.onGetAccountList();
    },
    filters: {
      onAccountType(val){
        let type={
          1:"支付宝",
          2:"微信"
        }
        return type[val];
      }
    },
    methods:{
       onGetAccountList() {//拉取列表
        let vm = this;
        const params = {
          rows:vm.page_size,
          page:vm.page_num,
          STORENAME:encodeURI(vm.kw),
          STORETYPE:vm.shoptype
        }
        vm.loading=true;
        getAccountList(params)
        .then(response => {
          let res = response.data;
          vm.tableData = res.rows;
          vm.total = res.total;
          vm.loading=false;
        })
        .catch(error => {
          vm.loading=false;
          console.log("拉取列表失败",error);
        });
      },
      handleSizeChange(val) {
        this.page_size = val;
        this.onGetAccountList();
      },
      handleCurrentChange(val) {
        this.page_num = val;
        this.onGetAccountList();
      },
      handleSelectionChange(val) {
      },
      onSearch(){//查询
        this.onGetAccountList();
      },
      onEidt(s_id){//编辑
        this.$router.push({
          path:"/accountInformationComponents",
          query:{
            type: 'update',
            id: s_id
          }
        })
      }
    }

  }


</script>



